
#ifndef MYDEFAULT
#define MYDEFAULT

class CDefault: public IDispatch {
	
	public:

	   // IUnknown
	   STDMETHOD(QueryInterface( REFIID, void** ));
	   STDMETHOD_(ULONG, AddRef());
	   STDMETHOD_(ULONG, Release());
	
	   // IDispatch
	   STDMETHOD( GetIDsOfNames(REFIID, OLECHAR FAR* FAR*, unsigned int, LCID, DISPID FAR*));
	   STDMETHOD( GetTypeInfo(unsigned int, LCID, ITypeInfo FAR* FAR*));
	   STDMETHOD( GetTypeInfoCount(unsigned int FAR*));
	   STDMETHOD( Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS FAR*, VARIANT FAR*, EXCEPINFO FAR*, unsigned int FAR*));

	CDefault();
	~CDefault();

        private:

		long	m_lRef;


};

CDefault::CDefault()
{
   m_lRef = 0;

   // Increment the global object count
   InterlockedIncrement( &g_lObjs ); 
}

// The destructor
CDefault::~CDefault()
{
   // Decrement the global object count
   InterlockedDecrement( &g_lObjs ); 
}

STDMETHODIMP CDefault::GetTypeInfo(unsigned int, LCID, ITypeInfo FAR* FAR*) { return E_NOTIMPL; }
STDMETHODIMP CDefault::GetTypeInfoCount(unsigned int FAR*) { return E_NOTIMPL; }
STDMETHODIMP CDefault::QueryInterface( REFIID riid, void** ppv )
{   
    *ppv = 0;
    if ( riid == IID_IUnknown ) 
        *ppv = this;
    if ( riid == IID_IDispatch )   *ppv = static_cast<IDispatch*>(this);
    if ( *ppv )
    {   AddRef();
        return( S_OK );
    };
    return (E_NOINTERFACE);
}

STDMETHODIMP_(ULONG) CDefault::AddRef()
{  
   return InterlockedIncrement( &m_lRef );
}

STDMETHODIMP_(ULONG) CDefault::Release()
{
   if ( InterlockedDecrement( &m_lRef ) == 0 ) {
	delete this;
	return 0;
   }	
   return m_lRef;
}

STDMETHODIMP CDefault::GetIDsOfNames( 
  REFIID riid,                  
  OLECHAR FAR* FAR*,  
  unsigned int,          
  LCID,                   
  DISPID FAR* 
)
{   
  if (riid != IID_NULL) return DISP_E_UNKNOWNINTERFACE;
  

  HRESULT hr = DISP_E_UNKNOWNNAME;

  return hr;
}

STDMETHODIMP CDefault::Invoke( 
  DISPID,      
  REFIID  riid,              
  LCID,                
  WORD  wFlags,              
  DISPPARAMS FAR*,  
  VARIANT FAR*,  
  EXCEPINFO FAR*,  
  unsigned int FAR*)
{   
  if (riid != IID_NULL) return DISP_E_UNKNOWNINTERFACE;

   // Make sure the wFlags are valid.
  if(wFlags & ~(DISPATCH_METHOD | DISPATCH_PROPERTYGET |
     DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF))
     return E_INVALIDARG;

  return E_FAIL;

};

#endif
